#include "DemoContainerCommon.h"
#include "DemoContainer.h"

#include "DemoContainerUnitTestGetItem.h"

DemoContainerSuiteStubGetItemTest::DemoContainerSuiteStubGetItemTest()
{
  uintTestData_.insert(std::map<int, std::string>::value_type(0, "dsfadsf&)(^*(&*^*(&^JHJHDSFLBASFKL45678567867$%&*%^&*%^&*^&"));
  uintTestData_.insert(std::map<int, std::string>::value_type(1, "Ddwfaf168/--%^^&()^%%KjhlkjHhlhkl"));
  uintTestData_.insert(std::map<int, std::string>::value_type(2, "&*)6789@#$%FGHJKTYUIO"));
  uintTestData_.insert(std::map<int, std::string>::value_type(3, "*/*-4987~!@#$"));
  uintTestData_.insert(std::map<int, std::string>::value_type(4, "1~@&#(kh"));
}

DemoContainerSuiteDriverGetItemTest::DemoContainerSuiteDriverGetItemTest()
{
  uintTestData_.insert(std::map<int, std::string>::value_type(0, "SDFADSFUNAS'SDIF[PDF"));
  uintTestData_.insert(std::map<int, std::string>::value_type(1, "~!@#$%^&*()~!@#$%^&*()!@#$%^&*WERTYUISDFGHJCVBNMGHJTYUI"));
  uintTestData_.insert(std::map<int, std::string>::value_type(2, "!@#$%^&*@#$%^&*$%^&*%^&*$%^&*$%^&$%^&*$%^&*$%^&*$%^&*(@#$%^&*()#$%^&*"));
  uintTestData_.insert(std::map<int, std::string>::value_type(3, "%^&*%^&*(34567890456789#$%^&$%^&8456789$%^&*(ughj<RTYUIOVBNM%^&*"));
  uintTestData_.insert(std::map<int, std::string>::value_type(4, "@#$%^&3$%^&*$%^&*34567834567899234567894567893456ERTYUIDFGHJVBNFG{:>}?}?FGHJK"));
}

TEST_F(DemoContainerSuiteStubGetItemTest, TestGetItemWhen0)
{
  DemoContainer container; 
  EXPECT_ANY_THROW( container.get_item( ZERO ) );
}

TEST_F(DemoContainerSuiteStubGetItemTest, TestGetItemWhenMinus)
{
  DemoContainer container; 
  EXPECT_ANY_THROW( container.get_item( MINUSONE ) );
}

TEST_F(DemoContainerSuiteStubGetItemTest, TestGetItemWhenEqualNum )
{
  DemoContainer container; 
  std::map<int, std::string> tmpData = this->get_usedata();

  for ( std::map<int, std::string>::iterator iter = tmpData.begin();
    iter != tmpData.end(); iter++)
  {
    container.add_item( iter->second );
  }

  EXPECT_ANY_THROW( container.get_item( (int)(tmpData.size()) ) );
}

TEST_F(DemoContainerSuiteStubGetItemTest, TestGetItemWhenGreaterNumThan1 )
{
  DemoContainer container; 
  std::map<int, std::string> tmpData = this->get_usedata();

  for ( std::map<int, std::string>::iterator iter = tmpData.begin();
    iter != tmpData.end(); iter++)
  {
    container.add_item( iter->second );
  }

  EXPECT_ANY_THROW( container.get_item( (int)(tmpData.size()) + 1 ) );
}

TEST_F(DemoContainerSuiteStubGetItemTest, TestGetItemWhenGreaterNumThan100 )
{
  DemoContainer container; 
  std::map<int, std::string> tmpData = this->get_usedata();

  for ( std::map<int, std::string>::iterator iter = tmpData.begin();
    iter != tmpData.end(); iter++)
  {
    container.add_item( iter->second );
  }

  EXPECT_ANY_THROW( container.get_item( (int)(tmpData.size()) + 100 ) );
}

TEST_F(DemoContainerSuiteDriverGetItemTest, TestGetItemWhen5Data )
{
  DemoContainer container; 
  std::map<int, std::string> tmpData = this->get_usedata();

  for ( std::vector<std::string>::size_type i = 0; i < tmpData.size(); i++ )
  {
    container.add_item( tmpData[i] );
  }

  EXPECT_STREQ( tmpData[ZERO].c_str(), container.get_item( ZERO ).c_str() );
  EXPECT_STREQ( tmpData[ONE].c_str(), container.get_item( ONE ).c_str() );
  EXPECT_STREQ( tmpData[TWO].c_str(), container.get_item( TWO ).c_str() );
  EXPECT_STREQ( tmpData[THREE].c_str(), container.get_item( THREE ).c_str() );
  EXPECT_STREQ( tmpData[FOUR].c_str(), container.get_item( FOUR ).c_str() );
}
